package company.controller;

import company.common.R;
import company.domain.Users;
import company.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author liuzewei
 * @ description
 * @ date 2024/6/25
 */
@RestController
public class HelloWorldController {
    @Autowired
    UsersService usersService;
    @Autowired
    RedisTemplate<String,Object> redisTemplate;

    @RequestMapping("/testRedisTemplate")
    public void testRedisTemplate() {
        this.redisTemplate.opsForValue().set("j:1","456");
    }


    @RequestMapping("/testRedisTemplate2")
    public Object
    testRedisTemplate2() {

        return this.redisTemplate.opsForValue().get("j:1");
    }

    @RequestMapping("/selectusersid/{id}")
    public R SelectAddressId(@PathVariable("id") int id){
        Users user = this.usersService.getById(id);
        return new R().add("user",user);
    }

}
